<html>
<head><meta charset="utf-8"><title>Building rustc-dev component · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html">Building rustc-dev component</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213265737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213265737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213265737">(Oct 14 2020 at 09:42)</a>:</h4>
<p>Hi all, I'm trying to do some println debugging in the compiler while developing a new -Zcodegen-backend, but when building a compiler using <code>./x.py dist</code>, adding the toolchain via <code>rustup toolchain link stage2 build/blah/stage2</code>, using that toolchain, and building my codegen-backend, I get "can't find crate rustc_ast".<br>
I think this means that the rustc-dev component wasn't built, or something like that - I know it's not built by default on stable, so is there maybe some flag I have to enable (in config.toml or something) to get it to be built?</p>



<a name="213266490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213266490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213266490">(Oct 14 2020 at 09:51)</a>:</h4>
<p>When using <code>./x.py dist</code> I think you need to use <code>./x.py dist rustc-dev</code> to build the <code>rustc-dev</code> component. If you just want to use <code>rustup toolchain link</code> you shouldn't use <code>./x.py dist</code>, but instead <code>./x.py build</code>. Maybe with <code>--stage 2</code>.</p>



<a name="213266667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213266667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213266667">(Oct 14 2020 at 09:52)</a>:</h4>
<p>Hmm, right, got confused by this page then, it seemed to imply that you needed <code>./x.py dist</code> to link the toolchain. <a href="https://rustc-dev-guide.rust-lang.org/building/build-install-distribution-artifacts.html">https://rustc-dev-guide.rust-lang.org/building/build-install-distribution-artifacts.html</a><br>
I'll try just <code>./x.py build --stage 2</code> then.</p>



<a name="213266945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213266945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213266945">(Oct 14 2020 at 09:55)</a>:</h4>
<p>While that's building, I also saw this - should this be nightly _or_ dev? not sure if this code is relevant <a href="https://github.com/rust-lang/rust/blob/5565241f65cf402c3dbcb55dd492f172c473d4ce/src/tools/build-manifest/src/main.rs#L377">https://github.com/rust-lang/rust/blob/5565241f65cf402c3dbcb55dd492f172c473d4ce/src/tools/build-manifest/src/main.rs#L377</a></p>



<a name="213267070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213267070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213267070">(Oct 14 2020 at 09:57)</a>:</h4>
<p>That is only for packaging I think. Also you are by default on the <code>dev</code> channel when building locally.</p>



<a name="213267979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213267979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213267979">(Oct 14 2020 at 10:06)</a>:</h4>
<p>Hmm, that still didn't work. There's nothing else I should have added to the <code>./x.py build --stage 2</code> command?</p>



<a name="213268168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213268168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213268168">(Oct 14 2020 at 10:08)</a>:</h4>
<p>Does linking <code>build/blah/stage1</code> work?</p>



<a name="213268394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213268394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213268394">(Oct 14 2020 at 10:11)</a>:</h4>
<p>Ah, looks like it did! Just had some compiler errors that I assumed were because it was trying to link against the outdated stage0 api, but no, looks like there's changes that haven't shipped in nightly yet (e.g. removing <code>rustc_codegen_ssa::back::write::dump_incremental_data</code>)</p>



<a name="213268732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213268732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213268732">(Oct 14 2020 at 10:16)</a>:</h4>
<p>I changed the codegen backend interface a bit in <a href="https://github.com/rust-lang/rust/issues/77795">#77795</a>, which landed 5 hours ago.</p>



<a name="213268818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213268818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213268818">(Oct 14 2020 at 10:16)</a>:</h4>
<p>Basically I moved a lot of common things out of the codegen backend into rustc_interface. I also removed <code>rustc_codegen_ssa::back::write::dump_incremental_data</code> as it didn't do anything at all.</p>



<a name="213269069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213269069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213269069">(Oct 14 2020 at 10:19)</a>:</h4>
<p>What codegen backend are you creating if I may ask?</p>



<a name="213269202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213269202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213269202">(Oct 14 2020 at 10:21)</a>:</h4>
<p>That's currently a (kind of badly-kept) secret, but we're hopefully open-sourcing in the next few weeks :)</p>



<a name="213269225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213269225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213269225">(Oct 14 2020 at 10:21)</a>:</h4>
<p>I see.</p>



<a name="213269432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213269432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213269432">(Oct 14 2020 at 10:24)</a>:</h4>
<p>Ah, right, now hitting the problem that I was hitting earlier with <a href="https://github.com/rust-lang/rust/pull/77565">https://github.com/rust-lang/rust/pull/77565</a> , "no ImplicitCtxt stored in tls". (funnily enough, that's the exact PR I'm trying to debug, I think I implemented it horribly wrong)</p>



<a name="213269507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213269507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213269507">(Oct 14 2020 at 10:25)</a>:</h4>
<p>I would have prefered the codegen backend was added only when using <code>-Zbinary-dep-depinfo</code> instead of unconditionally.</p>



<a name="213269587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213269587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213269587">(Oct 14 2020 at 10:26)</a>:</h4>
<p>I often make codegen backend changes that only affect specific pieces of code. I don't want to have to rebuild everything in that case.</p>



<a name="213270035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213270035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213270035">(Oct 14 2020 at 10:31)</a>:</h4>
<blockquote>
<p>"no ImplicitCtxt stored in tls"</p>
</blockquote>
<p>Are you spawning another thread?</p>



<a name="213270257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213270257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213270257">(Oct 14 2020 at 10:33)</a>:</h4>
<p>No. The exact same backend code works on nightly, so I'm guessing it's dynamic linking weirdness or something like that.</p>



<a name="213270408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213270408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213270408">(Oct 14 2020 at 10:35)</a>:</h4>
<p>Just a wild guess: Are you sure are compiling the backend using the same rustc as you want to load it into? Try <code>ldd</code> on both rustc and the codegen backend to find the <code>rustc_driver</code> version.</p>



<a name="213270703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213270703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213270703">(Oct 14 2020 at 10:39)</a>:</h4>
<p>well, <code>ldd</code> on the backend .so doesn't find it, because it's normally ran through <code>cargo +toolchain</code>, which I presume adds the proper dirs to LD_LIBRARY_PATH?</p>



<a name="213270758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213270758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213270758">(Oct 14 2020 at 10:39)</a>:</h4>
<p>You can use <code>rustup run stage2 ldd /path/to/codegen_backend.so</code>. (assuming that your toolchain is called stage2)</p>



<a name="213271130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213271130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213271130">(Oct 14 2020 at 10:44)</a>:</h4>
<p>well that's extremely bizzare, I built against stage1 (because stage2 "can't find crate rustc_ast"), but <code>rustup run stage1 ldd the_thing.so</code> doesn't find the .sos, but <code>rustup run stage2 ...</code> does.</p>



<a name="213271619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213271619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213271619">(Oct 14 2020 at 10:50)</a>:</h4>
<p>Strange. I don't know enough about bootstrap to know what is wrong.</p>



<a name="213273026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc-dev%20component/near/213273026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc-dev.20component.html#213273026">(Oct 14 2020 at 11:07)</a>:</h4>
<p>(I know nothing about that backend, but if it is what I think it is, I'm excited for that work to finally appear <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span>  :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>